package icu.stag.common.utils;

import cn.hutool.core.util.StrUtil;

public class StringUtils extends StrUtil {
    
    public static boolean isNotEmpty(String str) {
        return !isEmpty(str);
    }
    
    public static String formatPath(String path) {
        if (isEmpty(path)) {
            return "";
        }
        return path.replaceAll("//", "/");
    }
    
    public static String hidePhone(String phone) {
        if (isEmpty(phone) || phone.length() != 11) {
            return phone;
        }
        return phone.replaceAll("(\\d{3})\\d{4}(\\d{4})", "$1****$2");
    }
    
    public static String hideEmail(String email) {
        if (isEmpty(email) || !email.contains("@")) {
            return email;
        }
        String[] parts = email.split("@");
        String name = parts[0];
        String domain = parts[1];
        String hiddenName = name.substring(0, Math.min(3, name.length())) + "****";
        return hiddenName + "@" + domain;
    }
}